declare
fun {Tomar Xs N}
   
   if(N == 0) then [nil] 
   elseif(N > {Longitud Xs}) then Xs 
   else
      case Xs of X|Xr
      then
	 if(N == 1) then [X]
	 else
	    local N1 T in N1 = N - 1	       
	      {Tomar Xr N1 T}{Agregar [X] T} 
	    end	    
	 end	    
      else 
	 [nil]
      end
   end
end

fun {Agregar Xs Ys}
   case Xs of X|Xr then
      X|{Agregar Xr Ys}
   else
      Ys
   end
end

fun {Longitud Xs}
   case Xs of
      _|T then 1 + {Longitud T}
   else 0
   end
end

fun {Eliminar Xs N}
   if(N == 0) then Xs
   elseif(N > {Longitud Xs}) then [nil] 
   else
      case Xs of X|Xr
      then
	 if(N == 1) then Xr
	 else
	    local N1 in N1 = N - 1	       
	      {Eliminar Xr N1}
	    end	    
	 end	    
      else 
	 [nil]
      end
   end
end

fun {Miembro Xs Y}
   case Xs of X|Xr then
      if(X == Y)then true
      else
	 {Miembro Xr Y}
      end
   else
      false
   end
end

fun {Posicion Xs Y}
   case Xs of X|Xr then
      if(X == Y) then 0
      else
	 {Posicion Xr Y} + 1
      end
   else
      0
   end
end




   